#include <stdio.h>
#include <stdlib.h>

void get_array(int** arr_out,int len)
{
    *arr_out =(int*)malloc(len*sizeof(int));
    for(int i=0;i<len;i++)
    {
        scanf("%d",*arr_out+i);
    }
}

void Sort(int *arr_out,int len)
{
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < len-i-1; j++)
        {
            if (arr_out[j]>arr_out[j+1])
            {
                arr_out[j] ^= arr_out[j+1];
                arr_out[j+1] ^= arr_out[j];
                arr_out[j] ^= arr_out[j+1];
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    int* num;
    int len = 5;

    get_array(&num,len);
    printf("排序前的结果为:\n");
    for (int i = 0; i < len; i++)
    {
         printf("num[%d]为%d\n",i,num[i]);
    }
    
    Sort(num,len);
    printf("排序后的结果为:\n");
    for (int i = 0; i < len; i++)
    {
         printf("num[%d]为%d\n",i,num[i]);
    }

    if(num != NULL)
    {
        free(num);
        num = NULL;
    }

    return 0;
}
